%% qMT Compressed Sensing Script
%


%% Clean Matlab
%

clear all
close all
clc

%% Setup Study
%

mt_study_info
Rfactor=2;

%% Load Raw Data
%

switch seqType
    case 'uk'
        [mrprot, mdh, fid] = rdMeas(rawDataFilename);
        rawKSpace = reorder_raw_siemens_mridata(fid,mdh,'mt');
end

numFE=size(rawKSpace,1);
numPE=size(rawKSpace,2);
numMT=size(rawKSpace,4);
numChannel=size(rawKSpace,5);

%% Undersample k-space
%

mask = createUndersampleMask(mask_flag,underSampleMethod,Rfactor,numPE,numFE);

%% Mask k-space data
%

%Same k-space mask for all qMT points

for mtPointIndex = 1:numMT
    for channelIndex = 1:numChannel
        
        rawKSpace(:,:,1,mtPointIndex, channelIndex)=rawKSpace(:,:,1,mtPointIndex, channelIndex).*mask;

    end
end

%% Get Sum of Squares Reconstructed data
%

for mtPointIndex = 1:numMT
   magnVolume(:,:,mtPointIndex) = recon_multichannel_kspace(squeeze(rawKSpace(:,:,:,mtPointIndex,:)), mrprot); 
   
   figure()
   %imagesc(magnVolume(:,:,mtPointIndex))
   imshow(magnVolume(:,:,mtPointIndex)./max(max(magnVolume(:,:,mtPointIndex))))

   axis image
   drawnow
   pause(1)
 
end
